// axios的二次封装
import axios from 'axios'
import store from '@/store'
const requset = axios.create({
  baseURL: '/api',
  timeout: 5000
})

requset.interceptors.request.use(config => {
  // 获取到vuex里面的token
  const token = store.state.user.userDate.token
  // console.log(token)
  // 注入到请求头中 目前没用
  config.headers.Authorization = token

  return config
}, err => {
  return Promise.reject(err)
})

requset.interceptors.response.use(response => {
  // console.log(response)

  return response.data
}, err => {
  return Promise.reject(err)
})
export default requset
